package pl.register.android.util;

import android.view.View;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mateusz Strzelecki
 * @since 2013-04-21
 */

public class CompositeOnClickListener implements View.OnClickListener {

	private final List<View.OnClickListener> delegates;

	public CompositeOnClickListener(View.OnClickListener... listeners) {
		delegates = new ArrayList<View.OnClickListener>();

		for (View.OnClickListener listener : listeners) {
			add(listener);
		}
	}

	public void add(View.OnClickListener listener) {
		delegates.add(listener);
	}

	@Override
	public void onClick(View v) {
		for (View.OnClickListener listener : delegates) {
			listener.onClick(v);
		}
	}
}